package jpa4azure.type;

import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;

import javax.persistence.Entity;


public class Utils {

	public static void runtime(Exception e) {
		throw new RuntimeException(e);
	}

	public static void runtime(String msg, Exception e) {
		throw new RuntimeException(msg, e);
	}

	public static Class<?> genericType(Field f) {
		ParameterizedType t = (ParameterizedType) f.getGenericType();
		Class<?> genericType = (Class<?>) t.getActualTypeArguments()[0];
		return genericType;
	}
	
	public static boolean isEntity(Class<?> c) {
		while (c!= null && ! c.isAnnotationPresent(Entity.class))
			c = c.getSuperclass();
		return c!=null;
	}

}